﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace IDAdmin.Controls
{
    public partial class CountToolBar : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if(string.IsNullOrEmpty(beginDateTextBox.Text))
            {
                beginDateTextBox.Text = DateTime.Now.AddDays(-1).ToString("dd/MM/yyyy");
            }

            if(string.IsNullOrEmpty(toDateTextBox.Text))
            {
                toDateTextBox.Text = DateTime.Now.AddDays(-1).ToString("dd/MM/yyyy");
            }

            if(DateTime.ParseExact(beginDateTextBox.Text,"dd/MM/yyyy",CultureInfo.InvariantCulture).CompareTo(DateTime.ParseExact(toDateTextBox.Text,"dd/MM/yyyy",CultureInfo.InvariantCulture))>0)
            {
                beginDateTextBox.Text = DateTime.Now.AddDays(-1).ToString("dd/MM/yyyy");
                toDateTextBox.Text = DateTime.Now.AddDays(-1).ToString("dd/MM/yyyy");
            }
        }
    }
}